Skip to main content

Compile Contract

Prerequisites
  • Set up the VC Environment: Ensure you have the required tools installed. Setup Inery CDT
    check version of inery-cpp compiler with inery-cpp --version command
  • Write Your Contract: Define contract structure and logic.

Use inery-cpp to compile the contract. The output will be a WebAssembly (.wasm) file and an ABI file required for contract deployment.

Run the following command to compile the hello.cpp contract:

Compile Command
inery-cpp -o database.cpp database.wasm --abigen
Explanation
  • -o hello.wasm: Output WebAssembly file.
  • --abigen: Generates an ABI file (hello.abi), which defines the contract interface.

After running the command, you should see database.wasm and database.abi in your directory.

Example Output
Warning, empty ricardian clause file
Warning, action <upsert> does not have a ricardian contract
Warning, action <deleteentry> does not have a ricardian contract
Warning, action <upsert> does not have a ricardian contract
Warning, action <deleteentry> does not have a ricardian contract

Set Up Your Database on Ledger

To deploy compiled value contract on node, you need a blockchain database account. Follow these steps to create your database:

Deploy the Contract

Use cline set contract to deploy the contract to your inery database.

Set Value Contract
cline set contract database ./ database.wasm database.abi -p database@active
Explanation
  • database: Your database name.
  • ./ : Directory where hello.wasm and hello.abi are located.
  • -p database@active: Specifies the permission to deploy (use your account’s active permission).
Example output
Reading WASM from /root/database/database.wasm...
Publishing contract...
executed transaction: 8bd45c07bfda0668a018d0687eb5a57fadbc0071f9c591feac9eebd7f60c21a6 4512 bytes 3759 us
# inery <= inery::setcode {"account":"database","vmtype":0,"vmversion":0,"code":"0061736d01000000019e011a60000060017e0060047e7...
# inery <= inery::setabi {"account":"database","abi":"0e696e6572793a3a6162692f312e31000310636f6e7461696e65725f737472756374000...
warning: transaction executed locally, but may not be confirmed by the network yet ]